//
//  HttpContractAction.m
//  EPBPro
//
//  Created by wucha on 2018/6/25.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "HttpContractAction.h"

@implementation HttpContractAction
+(void)postContractListWithAction:(ContractActionInfo*)contractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionSearchContract parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:contractActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getContractListResultWithResponseData:) finish:block];
}

+(void)postAddContractWithAction:(AddContractActionInfo*)addContractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionAddContract parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:addContractActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getAddContractResultWithResponseData:) finish:block];

}

+(void)putModifyContractWithAction:(AddContractActionInfo*)addContractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionModifyContract parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:addContractActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getModifyContractResultWithResponseData:) finish:block];
    
}

+(void)getContractInfoWithID:(NSString*)contractID block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:[NSString stringWithFormat:@"%@%@",ActionSearchContractBYID,contractID] parmasAndKeys:nil];
    [self requestWithRequest:requestString jsonParserSelector:@selector(getContractIDResultWithResponseData:) finish:block];

}

+(void)deleteContractInfoWithID:(NSString*)contractID block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:[NSString stringWithFormat:@"%@%@",ActionSearchContractBYID,contractID] parmasAndKeys:nil];
    [self deleteRequestWithRequest:requestString withParam:nil jsonSelector:@selector(getContractDeleteResultWithResponseData:) finish:block];
    
}

#pragma mark-客户合同
+(void)postCustomerContractList:(ContractActionInfo*)contractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionSearchCustomerContract parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:contractActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getCustomerContractListResultWithResponseData:) finish:block];
}

+(void)postConfirmContract:(NSString*)contractId block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionConfirmationContract parmasAndKeys:nil];
    [self postRequestWithRequest:requestString withParam:@{@"id":contractId} jsonSelector:@selector(getConfirmContractResultWithResponseData:) finish:block];

}

+(void)postTerminateContract:(NSString*)contractId block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionTerminateContract parmasAndKeys:nil];
    [self postRequestWithRequest:requestString withParam:@{@"id":contractId} jsonSelector:@selector(getConfirmContractResultWithResponseData:) finish:block];

}

+(void)postContractEquipmentList:(NSDictionary*)dic block:(HTTPResultBlock)block{
    NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithDictionary:dic];
    [dic1 setObject:[NSNumber numberWithInt:0] forKey:@"offset"];
    NSString *requestString = [Utils getUrlWithAction:[NSString stringWithFormat:@"%@%@/equipments",ActionOrgContract,dic[@"contactId"]] parmasAndKeys:nil];
    [self postRequestWithRequest:requestString withParam:dic1 jsonSelector:@selector(getEquipmentListResultWithResponseData:) finish:block];

}

+(void)getRemindList:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionRemindList parmasAndKeys:nil];
    [self requestWithRequest:requestString jsonParserSelector:@selector(getRemindListResultWithResponseData:) finish:block];
}

+(void)getContractTotalInfo:(NSDictionary*)dic block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionContractTotal parmasAndKeys:nil];    
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getContractTotalInfoResultWithResponseData:) finish:block];

}


@end
